[2/4] mm/pgalloc, arch/xtensa: Support BUILD_KERNEL on Xtensa - #19796
Draft
casaroli wants to merge 2 commits into
Draft
[2/4] mm/pgalloc, arch/xtensa: Support BUILD_KERNEL on Xtensa#19796casaroli wants to merge 2 commits into
casaroli wants to merge 2 commits into
Conversation
casaroli
marked this pull request as draft
August 11, 2026 14:23
simbit18
requested review from
eren-terzioglu,
fdcavalcanti,
gustavonihei and
tmedicci
August 11, 2026 14:39
casaroli
force-pushed
the
xtensa-split-2-kernel
branch
2 times, most recently
from
August 11, 2026 15:30
4dce990 to
f87469e
Compare
casaroli
marked this pull request as ready for review
August 11, 2026 15:33
casaroli
force-pushed
the
xtensa-split-2-kernel
branch
from
August 11, 2026 20:06
f87469e to
f67dbec
Compare
casaroli
marked this pull request as draft
August 11, 2026 20:21
Contributor
Author
|
The goal is #19798, together with the ESP32-S3 chip code and the user mode isolation that a kernel build needs. But we have split it. Please review this one. |
Add CONFIG_MM_PGSIZE == 32768 and 65536 to the page-size switch (and the Kconfig help text). The 64 KB size matches the ESP32-S3 cache-MMU page granularity, so an address-environment port there can use one mm_pgalloc() page per cache-MMU page (naturally 64 KB-aligned by the granule allocator) instead of coalescing several smaller pages. Inert for existing configs: MM_PGSIZE is only used when CONFIG_MM_PGALLOC is enabled (BUILD_KERNEL). Assisted-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
Add what a kernel build needs on Xtensa: a crt0 for a user process, the kernel stack allocation that a system call switches to, the syscall entry and return path for an unprivileged caller, and the initial register state that starts a user task at EL0 with its save area on the kernel stack. On the ESP32-S3 the arch code that runs while the flash mapping is in flux moves to IRAM, and the kernel heap is placed above the user .bss so that up_allocate_kheap() and the user address environment do not overlap. Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
casaroli
force-pushed
the
xtensa-split-2-kernel
branch
from
August 28, 2026 17:53
f67dbec to
2f8f2f9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part 2 of 4, split from #19772. Two independent pieces, no chip or board code.
mm/pgallocgains 32 KB and 64 KB pages. It had 1 KB, 2 KB and 4 KB. The Espressif cache MMU has a fixed 64 KB page for external flash and 32 KB for external RAM.arch/xtensa/src/commongains whatBUILD_KERNELneeds and Xtensa lacked: a kernel stack for a user thread, a signal trampoline that returns through a system call, an initial register state that starts a user task at the right privilege, and the system call paths between the two worlds.One detail worth review. A stack pointer carries a base save area in the 16 bytes below it, holding the caller's spilled
a0-a3. Anything that builds or moves a stack pointer must leave it alone, so the signal trampoline reserves it explicitly rather than assuming the space below the pointer is free.This adds no
fork()orvfork()code and depends on nothing.Impact
None on any existing configuration. Xtensa can be built with
CONFIG_BUILD_KERNELafter this, but no chip provides an address environment yet, so nothing can be.mm/pgallocchanges no default.Testing
No kernel build is possible on this branch, so what is shown is that the common code compiles and does not disturb a flat build.
esp32s3-devkit:nshbuilds clean on this branch alone.esp32s3-devkit:ostestruns to the end on an ESP32-S3-DevKitC, WROOM-2 N32R8V:tools/checkpatch.sh -c -u -m -gpasses.